<?php
namespace Admin\Controller;
use  Think\Controller;
class GoodsUserController extends IndexController{
    public function lists(){
        $this->display();
    }
    public function get_lists(){
        $GoodsUser=D('Goods_user');
        if(I("request.iDisplayStart")==''){
            $start=0;
        }else{
            $start=I("request.iDisplayStart");
        }

        if(I("request.sSearch")!=''){
            $where="goods.uid=user.id AND goods.lid=shop.id AND goods.name like '%".I("request.sSearch")."%'";

        }else{
            $where="goods.uid=user.id AND goods.lid=shop.id";
        }



        $goods_user_info= $GoodsUser->table('tb_goods_user goods,tb_user user,tb_shop_class shop')
            ->where($where)
            ->field("goods.id,goods.uid,goods.name,goods.en_name,goods.phone,goods.addr,goods.garden,goods.age,goods.papers_type,papers,is_order,user.name uid,shop.name lid")
            ->limit($start,I("request.iDisplayLength"))
            ->select();
         $result=array();
        foreach($goods_user_info as $key=>$value){
            $result[$key]=$value;
            $result[$key]['is_order']=$value['is_order']==0?"未下订单":"已下订单";
            $result[$key]['papers_type']=$value['papers_type']==0?"身份证":"护照";
            $result[$key]['garden']=$value['garden']==0?"女":"男";


        }
        if($result){
            $ret = array(
                "sEcho" => intval($_GET['sEcho']),
                "iTotalRecords" => $start,
                "iTotalDisplayRecords" =>$GoodsUser->count(),
                "aaData" => $result
            );
            echo json_encode($ret);exit;
        }else{
            echo json_encode(0);exit;
        }
    }
}